<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Disclosure extends Model
{
    use HasFactory;

    protected $fillable = ['title','project_id','type_id','schedule_id','region_id','clicks','videos','files','content','status'];

    const POSTONLY = ['title','project_id','type_id','schedule_id','region_id','clicks','videos','files','content','status'];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }


    public function project()
    {
        return $this->hasOne(Project::class,'id','project_id')->select('id','title','status');
    }

    public function type()
    {
        return $this->hasOne(DisclosureType::class,'id','type_id')->select('id','title');
    }

    public function users()
    {
        return $this->belongsToMany(User::class,'disclosure_users');
    }

}
